
#include "resultlog.h"

using namespace Tester;

ResultLog::ResultLog(std::ostream &out) : out(out) {}

void ResultLog::initTestCase(const char *name, const char *file) {
   out << "Test Case \"" << name << "\"";

   if(file) out << " in file \"" << file << "\"";

   out << std::endl;
}

void ResultLog::unexpected(const char *nameMethod, unsigned int count, const char *what) {
   out << "Error: Unexpected exception in \"" << nameMethod << "\"";
 
   out << std::endl << "What? \"" ;
   
   if(what) out << what; 
   else out << "<< Unknown >>";

   out << "\"";

   if(count > 0)
      out << " (CheckPoint " << count << ")";

   out << std::endl;
}

void ResultLog::fail(const char *nameMethod, unsigned int count, 
      const char *typeFail, int line) {

   out << "Fail: " << typeFail << " in \"" << nameMethod << "\"";

   if(line >= 0) out << " (Line " << line << ")";

   if(count > 0)
      out << " (CheckPoint " << count << ")";

   out << std::endl;
}

void ResultLog::pass(const char *nameMethod) {
   out << "Pass: " << nameMethod << std::endl;
}

void ResultLog::error(const char *nameMethod, const char *nameStage, const char *what) {

   out << "Error: " << nameStage << " of \"" << nameMethod << "\"";

   if(what) out << std::endl << "What? \"" << what << "\"";

   out << std::endl;
}

void ResultLog::finishTestCase(unsigned int numTests) {
   out << "-------------------------------" << std::endl;
}

ResultLog::~ResultLog() {}


